using System;
using System.ServiceModel;
using jSLApp.Client.MainService;
using jSLCore.Client.Utility;

namespace jSLApp.Client
{
    public static class Communication
    {
        private static MainServiceSyncedChannel _proxy;
        public static MainServiceSyncedChannel Proxy
        {
            get
            {
                if (_proxy == null)
                {
                    var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None)
                                               {MaxBufferSize = 2147483647
                                                   , MaxReceivedMessageSize = 2147483647
                                                   
                                                   ,SendTimeout = new TimeSpan(1,0,0,0),
                                                ReceiveTimeout = new TimeSpan(1, 0, 0, 0),
                                                TransferMode = TransferMode.StreamedResponse
                                               };
                    var address = new EndpointAddress(new Uri(UIHelper.GetCurrentWebHostAddress() + "MainService.svc"));
                    _proxy = new MainServiceSyncedChannel(basicHttpBinding, address);
                }

                return _proxy;
            }
        }
    }
}